package com.pym.Contoller;

import com.pym.pojo.staff;
import com.pym.sevice.staffService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import javax.servlet.http.HttpSession;

@Controller
public class UserController {

    @Autowired
    private staffService service;

   @RequestMapping("/user/login")
    public String Login(@RequestParam("username")String username, @RequestParam("password") String
           Password, HttpSession httpSession, Model model){
       int i = service.LoginByUsernameandByPassword(username, Password);
       System.out.println(i);
       if (i>0){
           httpSession.setAttribute("loginUser",username);
           return "redirect:/main.html";
       }else {
           System.out.println("傻逼");
           model.addAttribute("msg","登录和密码输入错误");

           return "index";
       }

   }

}
